<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
	<script>var ctx="${ctx}";</script>
	<head>
	    <meta charset="utf-8">
	    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	    <title>商品管理</title>
	    <meta name="keywords" content="体验,友好,高级管理台,易用,高性能,高扩展性,bootstrap框架,响应式后台">
	    <meta name="description" content="这是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
	    <meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
		<meta http-equiv="expires" content="Wed, 26 Feb 209908:21:57 GMT"> 
	    
		<link rel="shortcut icon" href="favicon.ico"> 
		<link href="${ctx}/static/css/bootstrap.min.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/font-awesome.min.css?v=4.4.0?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/footable/footable.core.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/summernote/summernote.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/summernote/summernote-bs3.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/plugins/laypage/laypage.css?v=${static_version}"  rel="stylesheet">
		<link href="${ctx}/static/css/plugins/iCheck/custom.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/chosen/chosen.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/animate.min.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/js/plugins/layer/laydate/laydate.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/webuploader/webuploader.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/style.min.css?v=${static_version}/" rel="stylesheet">
	    
	</head>
	<body class="gray-bg">
    	<div class="ibox float-e-margins">
    		<div class="ibox-content">
                <form class="form-group" id="goods_table_form">	
                	<input type="hidden" name="orderBy" value="sort asc">
                	<input type="hidden" name="saleId" value="${saleId }">
                	<div class="row">
						<perm:hasPermission code="goods/insertGet">
					    <div class="col-md-2  col-sm-2 ">
							<a  onclick="clickInsertGet('${saleId }')" class="btn btn-block btn-outline btn-primary">添加</a>
					    </div>
					    </perm:hasPermission>
					    <div class="col-md-2"><input name="keyword" type="text" placeholder="请输入关键字" class="form-control" /></div>
						<div class="col-md-1 col-sm-2">
							<button id="goods_table_search" type="button" class="btn btn-outline btn-block btn-primary">查询</button>
						</div>
                    </div>
                </form>
				<table id="goods_table" data-action="${ctx}/sale/joinList" data-datatable="true"  class="footable table table-stripped toggle-arrow-tiny">
				  	<thead>
					  	<tr>
					  		<th data-sort-ignore="true"  data-title="goodsSN" >编号</th>				
							<th data-sort-ignore="true"  data-title="goodsName" >名称</th>
							<th data-sort-ignore="true"  data-title="sort" data-hide="phone,tablet" data-type="callback" data-callback="initSaleSort">排序</th>
						  	<th data-sort-ignore="true"  data-crud="true" data-title='{"uid":"goodsId"}' data-hide="phone">操作
			      			  <div style="display: none;" class="center hidden-phone">
			      			  	  <perm:hasPermission code="goods/delete">
					      			  		<button onclick="deleteAjax(this)" style="margin-left:3px;" data-id=":uid" type="button" class="btn btn-primary btn-xs">删除</button>
								 </perm:hasPermission>
							  </div> 
		      		      	</th>
					  	</tr>
				  	</thead>
				  	<tbody>
				  	</tbody>
			  	</table>
			  	<div class="row">
			  		<div class="col-md-6" class="pull-left" id="page_left_text"></div>
			  		<div class="col-md-6"  id="page_text"></div>
			  	</div>
			</div>
		</div>
		
	<script src="${ctx}/static/js/jquery.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/bootstrap.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/footable/footable.all.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/validate/jquery.validate.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/validate/messages_zh.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/webuploader/webuploader.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/summernote/summernote.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/summernote/summernote-zh-CN.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/chosen/chosen.jquery.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/layer/laydate/laydate.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/iCheck/icheck.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/plugins/laypage/laypage.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/switchery/switchery.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/eModal.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/cookie.js?v=?v=${static_version}"></script>
	<script src="${ctx}/static/common/custom-datatable.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/content.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/contabs.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/common/common.js?v=${static_version}"></script>
	
	<script>
		$(document).ready(function() {
			init_page_datatable();
		});
		
		var initSaleSort=function(cData,cLable,row){
			return '<input value="'+cData+'" type="text" placeholder="排序" class="form-control"  onchange="changeSort(this,\''+row.goodsId+'\')"/>';
		}
		
		var clickInsertGet=function(saleId){
			location.href="${ctx}/sale/selectIndex?saleId="+saleId;
		}
		
		function changeSort(obj,goodsId){
			$.post("${ctx}/sale/joinUpd",{"saleId":"${saleId}","goodsId":goodsId,"sort":$(obj).val()},function(response){
				if(response.code==0){
					//alert("修改成功");
				}else{
					alert("修改失败");
				}
			})
		}
		
		var deleteAjax=function(me){
			$.confirm({
			    text: $(me).data("title")||"确定删除这条数据么?",
			    confirm: function() {
			    	$.ajax({  
						url:"${ctx}/sale/joinDel",  
						data:{
							goodsId:$(me).data("id"),
							saleId:"${saleId}"
						},   
						type: 'POST',
						dataType:'json',  
						success:function(response){
							if(response.code==0){
								init_page_datatable();
							}else{
							    $.confirm({cancelButton: "关   闭",title: '提示!',content: (me).data("title")+"错误!"||"删除数据错误!"});
							}
							return false;
						}  
				    }); 
			    },
			    cancel: function() {
			        return true;
			    }
			});
		}
	</script>
	
	</body>
</html>